#
# Copyright (c) 2021-2023 Arm Limited.
#
# SPDX-License-Identifier: MIT
#

cmake_minimum_required(VERSION 3.13.5)
project(pbc LANGUAGES C)


set(SOURCE_FILES
    "src/alloc.c"
    "src/array.c"
    "src/bootstrap.c"
    "src/context.c"
    "src/decode.c"
    "src/map.c"
    "src/pattern.c"
    "src/proto.c"
    "src/register.c"
    "src/rmessage.c"
    "src/stringpool.c"
    "src/varint.c"
    "src/wmessage.c")
	
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
                    ${CMAKE_CURRENT_SOURCE_DIR}/src)

if(LIBRARY_CONFIGURATION STREQUAL "SHARED")
    add_library(pbc SHARED ${SOURCE_FILES})
else()
    add_library(pbc ${SOURCE_FILES})
endif()

install(
    TARGETS pbc
    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
    FILES "pbc.h" "src/alloc.h" "src/array.h" "src/bootstrap.h" "src/context.h" "src/descriptor.pbc.h" "src/map.h" "src/pattern.h" "src/proto.h" "src/stringpool.h" "src/varint.h"
    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)